#include <reg51.h>
#define U unsigned
#define S static
U char code display[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};
U char com[] = {0x01, 0x02};

void delays(U time)
{
    U char x;
    TMOD = 0x10;
    for (x = 0; x < time; x++)
    {
        TH1 = (65536 - 50000) / 256;
        TL1 = (65536 - 50000) % 256;
        TR1 = 1;
        while (!TF1)
            ;
        TF1 = 0;
    }
}
U int num = 0, num2 = 0;
void max()
{
    U int i;
    for (i = 0; i < 10; i++)
    {
        P2 = ~(com[0]);
        P1 = display[num2];
        delays(1);
        P2 = ~(com[1]);
        P1 = display[num];
        delays(1);
    }
    num++;
    if (num > 9)
    {
        num = 0;
        num2 += 1;
    }
    if (num2 > 5)
    {
        num2 = 0;
    }
}

void main()
{
    while (1)
    {
        max();
    }
}